<include file="Public/min-header"/>
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<div class="wrapper">
    <include file="Public/breadcrumb"/>
    <section class="content ">
        <!-- Main content -->
        <div class="container-fluid">
            <div class="pull-right">
                <a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>
<!--				<a href="javascript:;" class="btn btn-default" data-url="#" onclick="get_help(this)"><i class="fa fa-question-circle"></i> 帮助</a>-->
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-list"></i> 给直播间添加推广产品</h3>
                </div>
                <div class="panel-body ">   
                    <!--表单数据-->
                        <!--通用信息-->
                    <div class="tab-content col-md-10">                 	  
                        <div class="tab-pane active" id="tab_tongyong">   

<!--                          	<div class="callout callout-inro">-->

<!--						        <p>1：首页和积分商城banner广告:支持jpg、jpeg、png格式上传，建议图片750*360、大小1.00M以内的图片。</p>-->
<!--								<p>2：产品分类页面广告:支持jpg、jpeg、png格式上传，建议图片宽度552*180、大小1.00M以内的图片。</p>-->

<!--				            </div>-->
                        </div> 
                            <table class="table table-bordered">
                                <tbody>
                                <tr>
                                    <td class="col-sm-2">产品ID：</td>
                                    <td class="col-sm-6">
                                        <input type="text" class="form-control" id="goods_id" value=""/>
                                    </td>
                                    <td class="col-sm-2"><input class="btn btn-primary" type="button" id="add_goods"  value="添加"></td>
                                </tr>
                                <foreach name="live_goods" item="vo" key="k" >
                                <tr>
                                    <td class="col-sm-2"><input type="text" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onchange="updateSort('live_goods','id','{$vo.id}','number',this)" size="4" value="{$vo.number}" class="input-sm" />号链接：</td>
                                    <td class="col-sm-6">
                                        <img alt="" src="{$vo.original_img}" width="80px" height="50px"> <span>{$vo.goods_name}</span>
                                    </td>
                                    <td class="col-sm-2">
                                        <if condition="$vo.is_explain eq 0">
                                                <a class="btn btn-primary" onclick="goTop(this)" data-url="{:U('live/send_goods_live')}"  data-liveid="{$live_id}" data-goodsid="{$vo.goods_id}">推送讲解</a>
                                            <else/>
                                                <a class="btn btn-danger">讲解中</a>
                                        </if>

                                        <a class="btn btn-danger" onclick="delfunc(this)" data-url="{:U('live/goods')}" data-id="{$vo.id}" value="删除"><i class="fa fa-trash-o"></i></a>

<!--                                        <a class="btn btn-primary" onclick="cancelTop(this)" data-id="{$vo.id}">取消置顶</a>-->
                                    </td>
                                </tr>
                                </foreach>


                                </tbody>
                                <tfoot>
                                	<tr>
                                	<td><input type="hidden" name="act" value="{$act}">
                                        <input type="hidden" id="live_id" name="live_id" value="{$live_id}">
                                	</td>

                                </tfoot>
                            </table>
                        </div>                           
                    </div>              
                </div>
            </div>
    </section>
</div>
<script>
    $(function(){
        $('#add_goods').click(function () {
            if($('#goods_id').val()){
                $.ajax({
                    type : 'post',
                    url : '/index.php?m=Admin&c=Live&a=goods',
                    data : {live_id:$('#live_id').val(),goods_id:$('#goods_id').val(),act:'add'},
                    dataType : 'json',
                    success : function(data){
                        if(data){
                            layer.msg('操作成功', {icon: 1});
                            location.reload();
                        }else{
                            layer.msg(data, {icon: 2,time: 2000});
                        }
//   						layer.closeAll();
                    }
                })
            }else{
                layer.msg('请输入产品ID', {icon: 2,time: 2000});
            }

        })
    })


    function goTop(obj){
        layer.confirm('确认推送该产品到直播间吗？', {
                btn: ['确定','取消'] //按钮
            }, function(){
                // 确定
                $.ajax({
                    type : 'post',
                    url : $(obj).attr('data-url'),
                    data : {live_id:$(obj).attr('data-liveid'),goods_id:$(obj).attr('data-goodsid')},
                    dataType : 'json',
                    success : function(data){
                        if(data.code==1){
                            layer.msg('推送成功', {icon: 1},function () {
                                location.reload();
                            });

                        }else{
                            layer.msg(data, {icon: 2,time: 2000});
                        }
//   						layer.closeAll();
                    }
                })
            }, function(index){
                layer.close(index);
                return false;// 取消
            }
        );
    }

</script>
 </body>
 </html>